package vip.zhenzicheng.rabbitmq.pubsub;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import vip.zhenzicheng.rabbitmq.utils.RabbitConstant;
import vip.zhenzicheng.rabbitmq.utils.RabbitUtils;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

/**
 * @author zhenzicheng
 * @DESCRIPTION: 发布者，模拟发送信息
 * @DATE: 2022/04/25 2:54 PM
 */
public class WeatherBureau {
  public static void main(String[] args) throws IOException, TimeoutException {
    Connection conn = RabbitUtils.getConnection();
    String input = new Scanner(System.in).next();
    Channel channel = conn.createChannel();

    /*
     * @param 1 交换机
     */
    channel.basicPublish(RabbitConstant.EXCHANGE_WEATHER, "", null, input.getBytes());
    channel.close();
    conn.close();
  }
}
